package com.dt.platform.generator.module.oa;

import com.dt.platform.constants.db.OaTables;
import com.dt.platform.generator.config.Config;
import com.dt.platform.oa.page.FinCollectionRecordPageController;
import com.dt.platform.proxy.oa.FinCollectionRecordServiceProxy;
import com.github.foxnic.generator.builder.view.config.DatePickerType;
import com.github.foxnic.generator.config.WriteMode;
import org.github.foxnic.web.domain.hrm.Employee;

public class FinRecordCollectTicketGtr extends BaseCodeGenerator {


    public FinRecordCollectTicketGtr() {
        super(OaTables.OA_FIN_COLLECTION_RECORD.$TABLE,"876475835756838912");
    }

    public void generateCode() throws Exception {
        System.out.println(this.getClass().getName());

        cfg.getPoClassFile().addSimpleProperty(Employee.class,"originator","originator","originator");
        cfg.view().field(OaTables.OA_FIN_COLLECTION_RECORD.ID).basic().hidden(true);
        cfg.view().field(OaTables.OA_FIN_COLLECTION_RECORD.NOTES).search();

        cfg.view().search().inputLayout(
                new Object[]{
                        OaTables.OA_FIN_COLLECTION_RECORD.NOTES,
                }
        );
        cfg.view().search().labelWidth(1,Config.searchLabelWidth);
        cfg.view().search().labelWidth(2,Config.searchLabelWidth);
        cfg.view().search().labelWidth(3,Config.searchLabelWidth);
        cfg.view().search().labelWidth(4,Config.searchLabelWidth);
        cfg.view().search().inputWidth(Config.searchInputWidth);

        cfg.view().list().disableBatchDelete();

        cfg.view().search().disable();

        cfg.view().field(OaTables.OA_FIN_COLLECTION_RECORD.AMOUNT).form().validate().required().form().numberInput().defaultValue(0.0).scale(2);
        cfg.view().field(OaTables.OA_FIN_COLLECTION_RECORD.RCD_DATE).form().validate().required().form().dateInput().type(DatePickerType.date).defaultNow().format("yyyy-MM-dd").search().range();

        cfg.view().field(OaTables.OA_FIN_COLLECTION_RECORD.CREATE_BY).table().disable(true);
        cfg.view().field(OaTables.OA_FIN_COLLECTION_RECORD.UPDATE_BY).table().disable(true);
        cfg.view().field(OaTables.OA_FIN_COLLECTION_RECORD.UPDATE_TIME).table().disable(true);
        cfg.view().field(OaTables.OA_FIN_COLLECTION_RECORD.CREATE_TIME).table().disable(true);
        cfg.view().field(OaTables.OA_FIN_COLLECTION_RECORD.OWNER_ID).table().disable(true);
        cfg.view().field(OaTables.OA_FIN_COLLECTION_RECORD.OWNER_TYPE).table().disable(true);
        cfg.view().field(OaTables.OA_FIN_COLLECTION_RECORD.NOTES).form().textArea().height(150);

        cfg.view().form().labelWidth(100);
        cfg.view().formWindow().bottomSpace(50);
        cfg.view().formWindow().width(Config.baseFormWidth_50);

        cfg.view().field(OaTables.OA_FIN_COLLECTION_RECORD.ORIGINATOR_ID).table().fillBy("originator","name");
        cfg.view().field(OaTables.OA_FIN_COLLECTION_RECORD.ORIGINATOR_ID).form().readOnly().form()
                .button().chooseEmployee(true);


        cfg.view().form().addGroup(null,
                new Object[] {
                        OaTables.OA_FIN_COLLECTION_RECORD.RCD_DATE,
                        OaTables.OA_FIN_COLLECTION_RECORD.AMOUNT,
                        OaTables.OA_FIN_COLLECTION_RECORD.NOTES,
                }

        );


        cfg.view().list().addToolButton("完成回款","finish","finish");
        cfg.view().list().addToolButton("完成回款(剩余不在支付)","partFinish","partFinish");

        cfg.view().list().addJsVariable("OWNER_ID","[[${ownerId}]]","ownerId");
        cfg.view().list().addJsVariable("OWNER_TYPE","[[${ownerType}]]","ownerType");
        cfg.view().list().addJsVariable("PAGE_TYPE","[[${pageType}]]","pageType");

        cfg.view().form().addJsVariable("OWNER_ID","[[${ownerId}]]","ownerId");
        cfg.view().form().addJsVariable("OWNER_TYPE","[[${ownerType}]]","ownerType");

        //文件生成覆盖模式
        cfg.overrides()
                .setServiceIntfAnfImpl(WriteMode.IGNORE) //服务与接口
                .setControllerAndAgent(WriteMode.IGNORE) //Rest
                .setPageController(WriteMode.IGNORE) //页面控制器
                .setFormPage(WriteMode.COVER_EXISTS_FILE) //表单HTML页
                .setListPage(WriteMode.COVER_EXISTS_FILE)
                .setExtendJsFile(WriteMode.IGNORE); //列表HTML页
        //列表HTML页
        //生成代码
        cfg.buildAll();
    }

    public static void main(String[] args) throws Exception {
        FinRecordCollectTicketGtr g=new FinRecordCollectTicketGtr();
        //生成代码
        g.generateCode();

        //移除之前生成的菜单，视情况执行
//        g.removeByBatchId("471622036347682816");
        //生成菜单
        //
      //g.generateMenu(FinCollectionRecordServiceProxy.class, FinCollectionRecordPageController.class);
    }

}
